package bean.loader;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import dao.DAOFactory;

import bean.RuteBean;

public class RuteLoader implements BeanLoader<RuteBean>{

	@Override
	public List<RuteBean> loadList(ResultSet rs) throws SQLException {
		List<RuteBean> list = new ArrayList<RuteBean>();
		while(rs.next())
			list.add(loadSingle(rs));
		return list;
	}

	@Override
	public RuteBean loadSingle(ResultSet rs) throws SQLException {
		RuteBean bean = new RuteBean();
		bean.setKoordinat(DAOFactory.createKoordinatDao().getKoordinatWhereId(rs.getInt("ID_KOORD")));
		bean.setMaxSpeedAllowed(rs.getFloat("max_speed_allowed"));
		bean.setNamaRute(rs.getString("nama_rute"));
		bean.setUrutan(rs.getInt("urutan"));
		return bean;
	}

	@Override
	public PreparedStatement loadParameters(PreparedStatement ps, RuteBean bean)
			throws SQLException {
		return null;
	}

}
